# @Author: Eric Ito
# @Date: 1/29/2009
# @Name: Project Euler Problem 28


"""
21 22 23 24 25
20  7  8  9 10
19  6  1  2 11
18  5  4  3 12
17 16 15 14 13

What is the sum of the diagonals in a 1001x1001 spiral created just like
the above

"""

def main():
    rows = 3 # starting at second level
    inc = 2
    total = 1
    last = 1
    while rows <= 1001:
        # add the next 4 numbers for corners
        n1 = last + inc
        n2 = n1 + inc
        n3 = n2 + inc
        n4 = n3 + inc
        last = n4      #use this as starting point for next level

        total += n1 + n2 + n3 + n4  # add to total
        # each level means we are incrementing by 2 more than the last
        inc += 2
        rows += 2
    print total

if __name__ == "__main__":
    main()